home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Python / thread.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  2.5 KB  |  155 lines

  1. /* Thread package.
  2.    This is intended to be usable independently from Python.
  3.    The implementation for system foobar is in a file thread_foobar.h
  4.    which is included by this file dependent on config settings.
  5.    Stuff shared by all thread_*.h files is collected here. */
  6.  
  7. #include "config.h"
  8.  
  9. /* config.h may or may not define DL_IMPORT */
  10. #ifndef DL_IMPORT    /* declarations for DLL import/export */
  11. #define DL_IMPORT(RTYPE) RTYPE
  12. #endif
  13.  
  14. #ifndef DONT_HAVE_STDIO_H
  15. #include <stdio.h>
  16. #endif
  17.  
  18. #ifdef HAVE_STDLIB_H
  19. #include <stdlib.h>
  20. #else
  21. #ifdef Py_DEBUG
  22. extern char *getenv();
  23. #endif
  24. #endif
  25.  
  26. #ifdef HAVE_UNISTD_H
  27. #include <unistd.h>
  28. #endif
  29.  
  30. #ifdef __DGUX
  31. #define _USING_POSIX4A_DRAFT6
  32. #endif
  33.  
  34. #ifdef __sgi
  35. #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
  36. #undef _POSIX_THREADS
  37. #endif
  38. #endif
  39.  
  40. #include "pythread.h"
  41.  
  42. #ifdef __ksr__
  43. #define _POSIX_THREADS
  44. #endif
  45.  
  46. #ifndef _POSIX_THREADS
  47.  
  48. #ifdef __sgi
  49. #define SGI_THREADS
  50. #endif
  51.  
  52. #ifdef HAVE_THREAD_H
  53. #define SOLARIS_THREADS
  54. #endif
  55.  
  56. #if defined(sun) && !defined(SOLARIS_THREADS)
  57. #define SUN_LWP
  58. #endif
  59.  
  60. #ifdef __MWERKS__
  61. #define _POSIX_THREADS
  62. #endif
  63.  
  64. #endif /* _POSIX_THREADS */
  65.  
  66. #ifdef __STDC__
  67. #define _P(args)        args
  68. #define _P0()            (void)
  69. #define _P1(v,t)        (t)
  70. #define _P2(v1,t1,v2,t2)    (t1,t2)
  71. #else
  72. #define _P(args)        ()
  73. #define _P0()            ()
  74. #define _P1(v,t)        (v) t;
  75. #define _P2(v1,t1,v2,t2)    (v1,v2) t1; t2;
  76. #endif /* __STDC__ */
  77.  
  78. #ifdef Py_DEBUG
  79. static int thread_debug = 0;
  80. #define dprintf(args)    ((thread_debug & 1) && printf args)
  81. #define d2printf(args)    ((thread_debug & 8) && printf args)
  82. #else
  83. #define dprintf(args)
  84. #define d2printf(args)
  85. #endif
  86.  
  87. static int initialized;
  88.  
  89. static void PyThread__init_thread(); /* Forward */
  90.  
  91. void PyThread_init_thread _P0()
  92. {
  93. #ifdef Py_DEBUG
  94.     char *p = getenv("THREADDEBUG");
  95.  
  96.     if (p) {
  97.         if (*p)
  98.             thread_debug = atoi(p);
  99.         else
  100.             thread_debug = 1;
  101.     }
  102. #endif /* Py_DEBUG */
  103.     if (initialized)
  104.         return;
  105.     initialized = 1;
  106.     dprintf(("PyThread_init_thread called\n"));
  107.     PyThread__init_thread();
  108. }
  109.  
  110. #ifdef SGI_THREADS
  111. #include "thread_sgi.h"
  112. #endif
  113.  
  114. #ifdef SOLARIS_THREADS
  115. #include "thread_solaris.h"
  116. #endif
  117.  
  118. #ifdef SUN_LWP
  119. #include "thread_lwp.h"
  120. #endif
  121.  
  122. #ifdef _GNU_PTH
  123. #include "thread_pth.h"
  124. #else
  125. #ifdef _POSIX_THREADS
  126. #include "thread_pthread.h"
  127. #endif
  128. #endif
  129.  
  130. #ifdef C_THREADS
  131. #include "thread_cthread.h"
  132. #endif
  133.  
  134. #ifdef NT_THREADS
  135. #include "thread_nt.h"
  136. #endif
  137.  
  138. #ifdef OS2_THREADS
  139. #include "thread_os2.h"
  140. #endif
  141.  
  142. #ifdef BEOS_THREADS
  143. #include "thread_beos.h"
  144. #endif
  145.  
  146. #ifdef WINCE_THREADS
  147. #include "thread_wince.h"
  148. #endif
  149.  
  150. /*
  151. #ifdef FOOBAR_THREADS
  152. #include "thread_foobar.h"
  153. #endif
  154. */
  155.